;Routines for the custom S.A.D. font. These routines are used so the interrupt
;routine can run



Put_Text_Zero_End:

	SET Font_Mode, (IY + flag + 1)

	;hl is the text to display.  The text must end in a zero.
	;PenRow and PenCol are the X, Y coordinates.

Read_Text_Loop:		;Read a character of HL to draw text

	ld a, (PenCol)
	ld c, a		;Saves the pencol coordinates
	

	ld a, (hl)
	or a
	jr z, _

	call Check_Length
	jr Draw_Text


_
	RES Font_Mode, (IY + flag + 1)
	ret 



Draw_Text:

	ld a, (hl)
	push hl

	sub $2F
	ld de, 6
	Call Multiply_DE_By_A
	ex de, hl
	
	ld ix, SAD_Font
	add ix, de
	ld a, 1
	ld (Sprite_Width), a
	ld b, 6

	ld a, (penRow)
	ld e, a


	pop hl
	ld a, (hl)
	push hl

	cp 92
	jr nz, _

	ld a, e
	sub 3
	ld e, a
	ld b, 8
_
	ld l, e
	ld a, c

	Call Put_Sprite_Overwrite

	pop hl
	inc hl

	jr Read_Text_Loop
	



Character_Normal_Length:

	ld a, c
	add a, 4
	ld (PenCol), a

	ld a, 1
	ret



Character_Two_Length:

	ld a, c
	add a, 2
	ld (PenCol), a

	ld a, 1
	ret

Character_Six_Length:

	ld a, c
	add a, 6
	ld (PenCol), a

	ld a, 1
	ret

Character_Eight_Length:

	ld a, c
	add a, 8
	ld (PenCol), a

	ld a, 1
	ret

Check_Length:

	cp $3A
	call c, Character_Normal_Length



	cp $4D
	call z, Character_Six_Length

	cp $57
	call z, Character_Six_Length

	cp 91
	call nc, Character_Eight_Length
	
	cp $3E
	call nc, Character_Normal_Length

	cp $3A
	call nc, Character_Two_Length

	ret


Put_Text_B_Length:

	SET Font_Mode, (IY + flag + 1)

Read_Text_Loop_2:		;Read a character of HL to draw text


	ld a, (PenCol)
	ld c, a		;Saves the pencol coordinates
	

	ld a, (hl)

	call Check_Length

	ld a, b
	or a
	jr nz, Draw_Text_2
	RES Font_Mode, (IY + flag + 1)
	
	ret z



Draw_Text_2:
	
	push bc

	ld a, (hl)
	
	push hl
	
	sub $2F
	ld de, 6
	Call Multiply_DE_By_A
	ex de, hl
	
	ld ix, SAD_Font
	add ix, de
	ld a, 1
	ld (Sprite_Width), a
	ld b, 6
	ld a, (penRow)
	ld e, a


	pop hl
	ld a, (hl)
	push hl

	cp 92
	jr nz, _

	ld a, e
	sub 3
	ld e, a
	ld b, 8
_
	ld l, e
	ld a, c

	Call Put_Sprite_Overwrite
	pop hl
	inc hl
	
	pop bc



	dec b
	jr Read_Text_Loop_2

SAD_Font:


	.db $00
	.db $00
	.db $00
	.db $00
	.db $00
	.db $00
	.db $E0
	.db $A0
	.db $A0
	.db $A0
	.db $E0
	.db $00
	.db $C0
	.db $40
	.db $40
	.db $40
	.db $E0
	.db $00
	.db $E0
	.db $20
	.db $E0
	.db $80
	.db $E0
	.db $00
	.db $E0
	.db $20
	.db $E0
	.db $20
	.db $E0
	.db $00
	.db $A0
	.db $A0
	.db $E0
	.db $20
	.db $20
	.db $00
	.db $E0
	.db $80
	.db $E0
	.db $20
	.db $E0
	.db $00
	.db $E0
	.db $80
	.db $E0
	.db $A0
	.db $E0
	.db $00
	.db $E0
	.db $20
	.db $20
	.db $20
	.db $20
	.db $00
	.db $E0
	.db $A0
	.db $E0
	.db $A0
	.db $E0
	.db $00
	.db $E0
	.db $A0
	.db $E0
	.db $20
	.db $E0
	.db $00
	.db $00
	.db $00
	.db $00
	.db $00
	.db $80
	.db $00
	.db $00
	.db $80
	.db $00
	.db $80
	.db $00
	.db $00
	.db $80
	.db $80
	.db $80
	.db $00
	.db $80
	.db $00
	.db $80
	.db $80
	.db $00
	.db $00
	.db $00
	.db $00
	.db $00
	.db $00
	.db $E0
	.db $00
	.db $00
	.db $00
	.db $A0
	.db $A0
	.db $00
	.db $00
	.db $00
	.db $00
	.db $E0
	.db $20
	.db $60
	.db $00
	.db $40
	.db $00
	.db $E0
	.db $A0
	.db $E0
	.db $A0
	.db $A0
	.db $00
	.db $E0
	.db $A0
	.db $C0
	.db $A0
	.db $E0
	.db $00
	.db $E0
	.db $80
	.db $80
	.db $80
	.db $E0
	.db $00
	.db $C0
	.db $A0
	.db $A0
	.db $A0
	.db $C0
	.db $00
	.db $E0
	.db $80
	.db $E0
	.db $80
	.db $E0
	.db $00
	.db $E0
	.db $80
	.db $E0
	.db $80
	.db $80
	.db $00
	.db $E0
	.db $80
	.db $80
	.db $A0
	.db $E0
	.db $00
	.db $A0
	.db $A0
	.db $E0
	.db $A0
	.db $A0
	.db $00
	.db $E0
	.db $40
	.db $40
	.db $40
	.db $E0
	.db $00
	.db $20
	.db $20
	.db $20
	.db $A0
	.db $E0
	.db $00
	.db $A0
	.db $A0
	.db $C0
	.db $A0
	.db $A0
	.db $00
	.db $80
	.db $80
	.db $80
	.db $80
	.db $E0
	.db $00
	.db $F8
	.db $A8
	.db $A8
	.db $A8
	.db $A8
	.db $00
	.db $E0
	.db $A0
	.db $A0
	.db $A0
	.db $A0
	.db $00
	.db $E0
	.db $A0
	.db $A0
	.db $A0
	.db $E0
	.db $00
	.db $E0
	.db $A0
	.db $E0
	.db $80
	.db $80
	.db $00
	.db $E0
	.db $A0
	.db $A0
	.db $E0
	.db $40
	.db $00
	.db $E0
	.db $A0
	.db $E0
	.db $C0
	.db $A0
	.db $00
	.db $E0
	.db $80
	.db $E0
	.db $20
	.db $E0
	.db $00
	.db $E0
	.db $40
	.db $40
	.db $40
	.db $40
	.db $00
	.db $A0
	.db $A0
	.db $A0
	.db $A0
	.db $E0
	.db $00
	.db $A0
	.db $A0
	.db $A0
	.db $A0
	.db $40
	.db $00
	.db $A8
	.db $A8
	.db $A8
	.db $A8
	.db $F8
	.db $00
	.db $A0
	.db $A0
	.db $40
	.db $A0
	.db $A0
	.db $00
	.db $A0
	.db $A0
	.db $E0
	.db $40
	.db $40
	.db $00
	.db $E0
	.db $20
	.db $40
	.db $80
	.db $E0
	.db $00

Crystal:

	.db %00111100
	.db %01000010
	.db %10111101
	.db %01000010
	.db %00111100
	.db %00000000


Lobster:

	.db %00000011
	.db %00001100
	.db %10010011
	.db %11111000
	.db %11111000
	.db %10010011
	.db %00001100
	.db %00000011


